﻿using EMoney.IStock.Client.Models.Boot;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace EMoney.IStock.Client.DataAccess.Boot
{
    /// <summary>
    /// 开机会面数据访问类
    /// </summary>
    public class BootDal
    {
        /// <summary>
        /// 获取大事件
        /// </summary>
        /// <returns></returns>
        public BigEvent GetBigEvent()
        {
            string sql = @"SELECT TOP 1 t.typeid,t.typename,t.dispatchname,t.imgurl,t.imgurlsmall,m.message FROM tb_news_type t
                        LEFT JOIN tb_news_message m ON t.typeid=m.typeid
                        WHERE t.eventindex>0 ORDER BY t.eventindex";

            return SQLHelper.GetDataByColumns<BigEvent>(ConnectionManager.Emfstock, sql, null);
        }

        /// <summary>
        /// 获取热门个股
        /// </summary>
        /// <returns></returns>
        public DataTable GetHotStock()
        {
            return SQLHelper.ExecuteGetTable(ConnectionManager.Emfstock, CommandType.StoredProcedure, "sp_web_qry_lask_stock_week_rank", null);
        }

        /// <summary>
        /// 获取周周赠送利器
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public List<UserFunc> GetUserFunc(int userid)
        {
            SQLTools tools = new SQLTools();

            tools.AddSqlParameter("pUserID", SqlDbType.Int, userid);

            return SQLHelper.GetProcedureDataByColumnsLst<UserFunc>(ConnectionManager.Emfstock, "sp_web_get_user_func", tools.GetSqlParameters());
        }
    }
}
